/**
 * 
 */
package sjtu.ist.warehouse4ws.model.file;

import java.util.ArrayList;

import sjtu.ist.warehouse4ws.jcr.RepositoryMoudl;


/**
 * @author 唐唯汉
 *
 */
public class VersionImp implements Version{
	private String name=null;
	private String path=null;
	ArrayList<View> views;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
	}
	public VersionImp(String path){
		this.path=path;
	}
	VersionImp(String name,String path){
		this.name=name;
		this.path=path;
		views=null;
	}
	public void viewsInit(RepositoryMoudl rm)
	{
		views = new ArrayList<View>();
		ArrayList<String> names = rm.getNodesNames(path);
		ArrayList<String> paths =rm.getNodesPathes(path);
		for (int i = 0; i < names.size(); i++) {
			views.add(new ViewImplement(names.get(i),paths.get(i)));
		}
	}
	@Override
	public ArrayList<View> getViews(RepositoryMoudl rm) {
		// TODO Auto-generated method stub
		if(views==null)viewsInit(rm);
		return views;
	}
}
